package com.recipe.controller;

import com.recipe.common.entity.Result;
import com.recipe.entity.DishLabel;
import com.recipe.service.DishLabelService;
import com.recipe.util.TreeUtils;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import java.util.List;

/**
 * (DishLabel)表控制层
 *
 * @author lzk
 * @since 2024-06-18 16:05:17
 */
@RestController
@RequestMapping("dishLabel")
@Slf4j
@RequiredArgsConstructor
public class DishLabelController {
    private final DishLabelService dishLabelService;

    @GetMapping("/getLabelsTree")
    public Result getLabelsTree() {
        List<DishLabel> list = dishLabelService.list();
        List<DishLabel> dishLabels = TreeUtils.buildTree(list);
        return Result.ok(dishLabels);
    }
}

